import {
  BootstrapIcon,
  BootstrapIconName,
  BootstrapIconProps,
  bootstrapIconNames,
} from "@axelor/ui/icons/bootstrap-icon";

import {
  MaterialIcon,
  MaterialIconProps,
  materialIconNames,
} from "@axelor/ui/icons/material-icon";
import { forwardRef } from "react";

const fa: Record<string, BootstrapIconProps["icon"]> = {
  "fa-glass": "cup-straw",
  "fa-music": "music-note-beamed",
  "fa-search": "search",
  "fa-envelope-o": "envelope",
  "fa-heart": "heart",
  "fa-star": "star-fill",
  "fa-star-o": "star",
  "fa-user": "person-fill",
  "fa-film": "film",
  "fa-th-large": "grid-fill",
  "fa-th": "grid-3x3-gap-fill",
  "fa-th-list": "list-task",
  "fa-check": "check",
  "fa-times": "x",
  "fa-search-plus": "zoom-in",
  "fa-search-minus": "zoom-out",
  "fa-power-off": "power",
  "fa-signal": "reception-4",
  "fa-cog": "gear",
  "fa-trash-o": "trash",
  "fa-home": "house-fill",
  "fa-file-o": "file",
  "fa-clock-o": "clock",
  // "fa-road": "",
  "fa-download": "download",
  "fa-arrow-circle-o-down": "arrow-down-left-circle",
  "fa-arrow-circle-o-up": "arrow-up-left-circle",
  "fa-inbox": "inbox",
  "fa-play-circle-o": "play-circle",
  "fa-repeat": "repeat",
  "fa-refresh": "arrow-repeat",
  "fa-list-alt": "card-list",
  "fa-lock": "lock-fill",
  "fa-flag": "flag-fill",
  "fa-headphones": "headphones",
  "fa-volume-off": "volume-off-fill",
  "fa-volume-down": "volume-down-fill",
  "fa-volume-up": "volume-up-fill",
  "fa-qrcode": "qr-code",
  "fa-barcode": "upc",
  "fa-tag": "tag-fill",
  "fa-tags": "tags-fill",
  "fa-book": "book",
  "fa-bookmark": "bookmark-fill",
  "fa-print": "printer",
  "fa-camera": "camera-fill",
  "fa-font": "fonts",
  "fa-bold": "type-bold",
  "fa-italic": "type-italic",
  // "fa-text-height": "",
  // "fa-text-width": "",
  "fa-align-left": "text-left",
  "fa-align-center": "text-center",
  "fa-align-right": "text-right",
  "fa-align-justify": "justify",
  "fa-list": "list-task",
  "fa-outdent": "text-indent-right",
  "fa-indent": "text-indent-left",
  "fa-video-camera": "camera-video-fill",
  "fa-picture-o": "image",
  "fa-pencil": "pencil-fill",
  "fa-map-marker": "geo-alt-fill",
  // "fa-adjust": "",
  // "fa-tint": "",
  "fa-pencil-square-o": "pencil-square",
  "fa-share-square-o": "share",
  "fa-check-square-o": "check-square",
  "fa-arrows": "arrows-move",
  // "fa-step-backward": "",
  "fa-fast-backward": "skip-backward",
  "fa-backward": "skip-backward",
  "fa-play": "play-fill",
  "fa-pause": "pause-fill",
  "fa-stop": "stop-fill",
  "fa-forward": "fast-forward-fill",
  "fa-fast-forward": "skip-forward-fill",
  "fa-step-forward": "forward-fill",
  "fa-eject": "eject-fill",
  "fa-chevron-left": "chevron-left",
  "fa-chevron-right": "chevron-right",
  "fa-plus-circle": "plus-circle-fill",
  "fa-minus-circle": "dash-circle-fill",
  "fa-times-circle": "x-circle-fill",
  "fa-check-circle": "check-circle-fill",
  "fa-question-circle": "question-circle-fill",
  "fa-info-circle": "info-circle-fill",
  "fa-crosshairs": "crosshair",
  "fa-times-circle-o": "x-circle",
  "fa-check-circle-o": "check-circle",
  "fa-ban": "ban",
  "fa-arrow-left": "arrow-left",
  "fa-arrow-right": "arrow-right",
  "fa-arrow-up": "arrow-up",
  "fa-arrow-down": "arrow-down",
  "fa-share": "share",
  "fa-expand": "arrows-angle-expand",
  "fa-compress": "arrows-angle-contract",
  "fa-plus": "plus-lg",
  "fa-minus": "dash-lg",
  "fa-asterisk": "asterisk",
  "fa-exclamation-circle": "exclamation-circle-fill",
  "fa-gift": "gift",
  // "fa-leaf": "",
  "fa-fire": "fire",
  "fa-eye": "eye-fill",
  "fa-eye-slash": "eye-slash",
  "fa-exclamation-triangle": "exclamation-triangle",
  "fa-plane": "airplane",
  "fa-calendar": "calendar",
  "fa-random": "shuffle",
  "fa-shuffle": "shuffle",
  "fa-comment": "chat-fill",
  "fa-magnet": "magnet-fill",
  "fa-chevron-up": "chevron-up",
  "fa-chevron-down": "chevron-down",
  // "fa-retweet": "",
  "fa-shopping-cart": "cart-fill",
  "fa-folder": "folder-fill",
  "fa-folder-open": "folder2-open",
  "fa-arrows-v": "arrows-vertical",
  "fa-arrows-h": "arrows",
  "fa-bar-chart": "bar-chart",
  "fa-twitter-square": "twitter",
  "fa-facebook-square": "facebook",
  "fa-camera-retro": "camera",
  "fa-key": "key",
  "fa-cogs": "gear",
  "fa-comments": "chat",
  "fa-thumbs-o-up": "hand-thumbs-up",
  "fa-thumbs-o-down": "hand-thumbs-down",
  "fa-star-half": "star-half",
  "fa-heart-o": "heart",
  "fa-sign-out": "box-arrow-right",
  "fa-linkedin-square": "linkedin",
  "fa-thumb-tack": "pin-fill",
  "fa-external-link": "box-arrow-up-right",
  "fa-sign-in": "box-arrow-in-right",
  "fa-trophy": "trophy",
  "fa-github-square": "github",
  "fa-upload": "upload",
  // "fa-lemon-o": "",
  "fa-phone": "telephone",
  "fa-square-o": "square",
  "fa-bookmark-o": "bookmark",
  "fa-phone-square": "telephone",
  "fa-twitter": "twitter",
  "fa-facebook": "facebook",
  "fa-github": "github",
  "fa-unlock": "unlock-fill",
  "fa-credit-card": "credit-card-fill",
  "fa-rss": "rss",
  "fa-hdd-o": "hdd",
  "fa-bullhorn": "megaphone",
  "fa-bell": "bell-fill",
  // "fa-certificate": "",
  // "fa-hand-o-right": "",
  // "fa-hand-o-left": "",
  "fa-hand-o-up": "hand-index-thumb",
  // "fa-hand-o-down": "",
  "fa-arrow-circle-left": "arrow-left-circle-fill",
  "fa-arrow-circle-right": "arrow-right-circle-fill",
  "fa-arrow-circle-up": "arrow-up-circle-fill",
  "fa-arrow-circle-down": "arrow-down-circle-fill",
  "fa-globe": "globe",
  "fa-wrench": "wrench",
  "fa-tasks": "list-task",
  "fa-filter": "funnel-fill",
  "fa-briefcase": "briefcase-fill",
  "fa-arrows-alt": "arrows-fullscreen",
  "fa-users": "people-fill",
  "fa-group": "people-fill",
  "fa-link": "link",
  "fa-cloud": "cloud-fill",
  // "fa-flask": "",
  "fa-scissors": "scissors",
  "fa-files-o": "files",
  "fa-paperclip": "paperclip",
  "fa-floppy-o": "save",
  "fa-square": "square-fill",
  "fa-bars": "list",
  "fa-list-ul": "list-task",
  "fa-list-ol": "list-ol",
  "fa-strikethrough": "type-strikethrough",
  "fa-underline": "type-underline",
  "fa-table": "table",
  "fa-magic": "magic",
  "fa-truck": "truck",
  "fa-pinterest": "pinterest",
  "fa-pinterest-square": "pinterest",
  // "fa-google-plus-square": "",
  // "fa-google-plus": "",
  "fa-money": "cash",
  "fa-caret-down": "caret-down-fill",
  "fa-caret-up": "caret-up-fill",
  "fa-caret-left": "caret-left-fill",
  "fa-caret-right": "caret-right-fill",
  "fa-columns": "layout-three-columns",
  "fa-sort": "sort-up",
  "fa-sort-desc": "sort-down",
  "fa-sort-down": "sort-down",
  "fa-sort-asc": "sort-up",
  "fa-sort-up": "sort-up",
  "fa-envelope": "envelope-fill",
  "fa-linkedin": "linkedin",
  "fa-undo": "arrow-counterclockwise",
  "fa-gavel": "hammer",
  "fa-tachometer": "speedometer",
  "fa-dashboard": "speedometer",
  "fa-comment-o": "chat",
  "fa-comments-o": "chat",
  "fa-bolt": "lightning-fill",
  "fa-sitemap": "diagram-3-fill",
  "fa-umbrella": "umbrella-fill",
  "fa-clipboard": "clipboard",
  "fa-lightbulb-o": "lightbulb",
  "fa-exchange": "arrow-left-right",
  "fa-cloud-download": "cloud-arrow-down-fill",
  "fa-cloud-upload": "cloud-arrow-up-fill",
  // "fa-user-md": "",
  // "fa-stethoscope": "",
  "fa-suitcase": "briefcase-fill",
  "fa-bell-o": "bell",
  "fa-coffee": "cup-hot-fill",
  // "fa-cutlery": "",
  "fa-file-text-o": "file-text",
  "fa-building-o": "building",
  "fa-hospital-o": "hospital",
  // "fa-ambulance": "",
  "fa-medkit": "file-medical-fill",
  "fa-fighter-jet": "airplane-fill",
  // "fa-beer": "",
  "fa-h-square": "h-square-fill",
  "fa-plus-square": "plus-square-fill",
  "fa-angle-double-left": "chevron-double-left",
  "fa-angle-double-right": "chevron-double-right",
  "fa-angle-double-up": "chevron-double-up",
  "fa-angle-double-down": "chevron-double-down",
  "fa-angle-left": "chevron-left",
  "fa-angle-right": "chevron-down",
  "fa-angle-up": "chevron-up",
  "fa-angle-down": "chevron-down",
  "fa-desktop": "pc-display-horizontal",
  "fa-laptop": "laptop",
  "fa-tablet": "tablet",
  "fa-mobile": "phone",
  "fa-circle-o": "circle",
  "fa-quote-left": "quote",
  "fa-quote-right": "quote",
  // "fa-spinner": "",
  "fa-circle": "circle-fill",
  "fa-reply": "reply-fill",
  "fa-github-alt": "github",
  "fa-folder-o": "folder",
  "fa-folder-open-o": "folder2-open",
  "fa-smile-o": "emoji-smile",
  "fa-frown-o": "emoji-frown",
  "fa-meh-o": "emoji-neutral",
  "fa-gamepad": "controller",
  "fa-keyboard-o": "keyboard",
  "fa-flag-o": "flag",
  "fa-flag-checkered": "flag",
  "fa-terminal": "terminal",
  "fa-code": "code-slash",
  "fa-reply-all": "reply-all-fill",
  "fa-star-half-o": "star-half",
  // "fa-location-arrow": "",
  // "fa-location": "",
  "fa-crop": "crop",
  // "fa-code-fork": "",
  // "fa-chain-broken": "",
  "fa-question": "question",
  "fa-info": "info",
  "fa-exclamation": "exclamation",
  "fa-superscript": "superscript",
  "fa-subscript": "subscript",
  "fa-eraser": "eraser-fill",
  "fa-puzzle-piece": "puzzle-fill",
  "fa-microphone": "mic-fill",
  "fa-microphone-slash": "mic-mute-fill",
  "fa-shield": "shield-shaded",
  "fa-calendar-o": "calendar",
  // "fa-fire-extinguisher": "",
  "fa-rocket": "rocket-takeoff-fill",
  // "fa-maxcdn": "",
  "fa-chevron-circle-left": "chevron-left",
  "fa-chevron-circle-right": "chevron-right",
  "fa-chevron-circle-up": "chevron-up",
  "fa-chevron-circle-down": "chevron-down",
  // "fa-html5": "",
  // "fa-css3": "",
  // "fa-anchor": "",
  "fa-unlock-alt": "unlock-fill",
  "fa-bullseye": "bullseye",
  "fa-ellipsis-h": "three-dots",
  "fa-ellipsis-v": "three-dots-vertical",
  "fa-rss-square": "rss",
  "fa-play-circle": "play-circle",
  "fa-ticket": "ticket-fill",
  "fa-minus-square": "dash-square-fill",
  "fa-minus-square-o": "dash-square",
  "fa-level-up": "arrow-90deg-up",
  "fa-level-down": "arrow-90deg-down",
  "fa-check-square": "check-square",
  "fa-pencil-square": "pencil-square",
  "fa-external-link-square": "box-arrow-up-right",
  "fa-share-square": "share",
  "fa-compass": "compass",
  "fa-caret-square-o-down": "caret-down-square",
  "fa-caret-square-o-up": "caret-up-square",
  "fa-caret-square-o-right": "caret-right-square",
  "fa-eur": "currency-euro",
  "fa-gbp": "currency-pound",
  "fa-usd": "currency-dollar",
  "fa-inr": "currency-rupee",
  "fa-jpy": "currency-yen",
  // "fa-rub": "",
  // "fa-krw": "",
  "fa-btc": "currency-bitcoin",
  "fa-file": "file-fill",
  "fa-file-text": "file-text",
  "fa-sort-alpha-asc": "sort-alpha-down",
  "fa-sort-alpha-desc": "sort-alpha-up",
  "fa-sort-amount-asc": "sort-up",
  "fa-sort-amount-desc": "sort-down",
  "fa-sort-numeric-asc": "sort-numeric-up",
  "fa-sort-numeric-desc": "sort-numeric-down",
  "fa-thumbs-up": "hand-thumbs-up-fill",
  "fa-thumbs-down": "hand-thumbs-down-fill",
  "fa-youtube-square": "youtube",
  "fa-youtube": "youtube",
  // "fa-xing": "",
  // "fa-xing-square": "",
  "fa-youtube-play": "youtube",
  "fa-dropbox": "dropbox",
  // "fa-stack-overflow": "",
  "fa-instagram": "instagram",
  // "fa-flickr": "",
  // "fa-adn": "",
  // "fa-bitbucket": "",
  // "fa-bitbucket-square": "",
  // "fa-tumblr": "",
  // "fa-tumblr-square": "",
  "fa-long-arrow-down": "arrow-down",
  "fa-long-arrow-up": "arrow-up",
  "fa-long-arrow-left": "arrow-left",
  "fa-long-arrow-right": "arrow-right",
  "fa-apple": "apple",
  "fa-windows": "windows",
  "fa-android": "android",
  // "fa-linux": "",
  "fa-dribbble": "dribbble",
  "fa-skype": "skype",
  // "fa-foursquare": "",
  "fa-trello": "trello",
  "fa-female": "gender-female",
  "fa-male": "gender-male",
  // "fa-gratipay": "",
  "fa-sun-o": "sun",
  "fa-moon-o": "moon",
  "fa-archive": "archive-fill",
  "fa-bug": "bug-fill",
  // "fa-vk": "",
  // "fa-weibo": "",
  // "fa-renren": "",
  // "fa-pagelines": "",
  // "fa-stack-exchange": "",
  "fa-arrow-circle-o-right": "arrow-right-circle",
  "fa-arrow-circle-o-left": "arrow-left-circle",
  "fa-caret-square-o-left": "caret-left-square",
  "fa-dot-circle-o": "record-circle",
  // "fa-wheelchair": "",
  "fa-vimeo-square": "vimeo",
  // "fa-try": "",
  "fa-plus-square-o": "plus-square",
  "fa-space-shuttle": "rocket-fill",
  "fa-slack": "slack",
  "fa-envelope-square": "envelope",
  "fa-wordpress": "wordpress",
  // "fa-openid": "",
  // "fa-university": "",
  "fa-graduation-cap": "mortarboard-fill",
  // "fa-yahoo": "",
  "fa-google": "google",
  "fa-reddit": "reddit",
  "fa-reddit-square": "reddit",
  // "fa-stumbleupon-circle": "",
  // "fa-stumbleupon": "",
  // "fa-delicious": "",
  // "fa-digg": "",
  // "fa-pied-piper-pp": "",
  // "fa-pied-piper-alt": "",
  // "fa-drupal": "",
  // "fa-joomla": "",
  "fa-language": "translate",
  // "fa-fax": "",
  "fa-building": "building",
  // "fa-child": "",
  // "fa-paw": "",
  // "fa-spoon": "",
  "fa-cube": "box",
  "fa-cubes": "boxes",
  "fa-behance": "behance",
  "fa-behance-square": "behance",
  "fa-steam": "steam",
  "fa-steam-square": "steam",
  "fa-recycle": "recycle",
  "fa-car": "car-front",
  "fa-taxi": "taxi-front-fill",
  "fa-tree": "tree-fill",
  "fa-spotify": "spotify",
  // "fa-deviantart": "",
  // "fa-soundcloud": "",
  "fa-database": "database-fill",
  "fa-file-pdf-o": "file-pdf",
  "fa-file-word-o": "file-word",
  "fa-file-excel-o": "file-excel",
  "fa-file-powerpoint-o": "file-ppt",
  "fa-file-image-o": "file-richtext",
  "fa-file-archive-o": "file-zip",
  "fa-file-audio-o": "file-music",
  "fa-file-video-o": "file-play",
  "fa-file-code-o": "file-code",
  // "fa-vine": "",
  // "fa-codepen": "",
  // "fa-jsfiddle": "",
  "fa-life-ring": "life-preserver",
  "fa-circle-o-notch": "power",
  // "fa-rebel": "",
  // "fa-empire": "",
  "fa-git-square": "git",
  "fa-git": "git",
  // "fa-hacker-news": "",
  // "fa-tencent-weibo": "",
  // "fa-qq": "",
  // "fa-weixin": "",
  "fa-paper-plane": "send-fill",
  "fa-paper-plane-o": "send",
  "fa-history": "arrow-counterclockwise",
  "fa-circle-thin": "circle",
  // "fa-header": "",
  "fa-paragraph": "paragraph",
  "fa-sliders": "sliders",
  "fa-share-alt": "share-fill",
  "fa-share-alt-square": "share-fill",
  // "fa-bomb": "",
  // "fa-futbol-o": "",
  // "fa-tty": "",
  "fa-binoculars": "binoculars-fill",
  "fa-plug": "plug-fill",
  // "fa-slideshare": "",
  "fa-twitch": "twitch",
  "fa-yelp": "yelp",
  "fa-newspaper-o": "newspaper",
  "fa-wifi": "wifi",
  "fa-calculator": "calculator",
  "fa-paypal": "paypal",
  "fa-google-wallet": "google",
  "fa-cc-visa": "credit-card",
  "fa-cc-mastercard": "credit-card",
  // "fa-cc-discover": "",
  "fa-cc-amex": "credit-card",
  "fa-cc-paypal": "paypal",
  "fa-cc-stripe": "stripe",
  "fa-bell-slash": "bell-slash-fill",
  "fa-bell-slash-o": "bell-slash",
  "fa-trash": "trash",
  "fa-copyright": "c-circle",
  "fa-at": "at",
  "fa-eyedropper": "eyedropper",
  "fa-paint-brush": "brush-fill",
  "fa-birthday-cake": "cake2-fill",
  "fa-area-chart": "graph-up",
  "fa-pie-chart": "pie-chart-fill",
  "fa-line-chart": "graph-up-arrow",
  // "fa-lastfm": "",
  // "fa-lastfm-square": "",
  "fa-toggle-off": "toggle-off",
  "fa-toggle-on": "toggle-on",
  "fa-bicycle": "bicycle",
  "fa-bus": "bus-front",
  // "fa-ioxhost": "",
  // "fa-angellist": "",
  "fa-cc": "badge-cc",
  // "fa-ils": "",
  // "fa-meanpath": "",
  // "fa-buysellads": "",
  // "fa-connectdevelop": "",
  // "fa-dashcube": "",
  // "fa-forumbee": "",
  // "fa-leanpub": "",
  // "fa-sellsy": "",
  // "fa-shirtsinbulk": "",
  // "fa-simplybuilt": "",
  // "fa-skyatlas": "",
  "fa-cart-plus": "cart-plus-fill",
  "fa-cart-arrow-down": "cart-fill",
  "fa-diamond": "gem",
  // "fa-ship": "",
  "fa-user-secret": "incognito",
  // "fa-motorcycle": "",
  "fa-street-view": "geo-fill",
  "fa-heartbeat": "heart-pulse-fill",
  "fa-venus": "gender-female",
  "fa-mars": "gender-male",
  // "fa-mercury": "",
  "fa-transgender": "gender-ambiguous",
  "fa-transgender-alt": "gender-trans",
  // "fa-venus-double": "",
  // "fa-mars-double": "",
  // "fa-venus-mars": "",
  // "fa-mars-stroke": "",
  // "fa-mars-stroke-v": "",
  // "fa-mars-stroke-h": "",
  // "fa-neuter": "",
  "fa-genderless": "circle",
  "fa-facebook-official": "facebook",
  "fa-pinterest-p": "pinterest",
  "fa-whatsapp": "whatsapp",
  "fa-server": "hdd-stack",
  "fa-user-plus": "person-plus-fill",
  "fa-user-times": "person-x-fill",
  // "fa-bed": "",
  // "fa-viacoin": "",
  "fa-train": "train-front-fill",
  "fa-subway": "train-front-fill",
  // "fa-medium": "",
  // "fa-y-combinator": "",
  // "fa-optin-monster": "",
  // "fa-opencart": "",
  "fa-expeditedssl": "file-earmark-lock2-fill",
  "fa-battery-full": "battery-full",
  "fa-battery-three-quarters": "battery-half",
  "fa-battery-half": "battery-half",
  "fa-battery-quarter": "battery-half",
  "fa-battery-empty": "battery",
  // "fa-mouse-pointer": "",
  "fa-i-cursor": "cursor-text",
  // "fa-object-group": "",
  // "fa-object-ungroup": "",
  "fa-sticky-note": "sticky-fill",
  "fa-sticky-note-o": "sticky",
  // "fa-cc-jcb": "",
  // "fa-cc-diners-club": "",
  "fa-clone": "copy",
  "fa-copy": "copy",
  // "fa-balance-scale": "",
  "fa-hourglass-o": "hourglass",
  "fa-hourglass-start": "hourglass-bottom",
  "fa-hourglass-half": "hourglass-split",
  "fa-hourglass-end": "hourglass-top",
  "fa-hourglass": "hourglass",
  // "fa-hand-rock-o": "",
  // "fa-hand-paper-o": "",
  // "fa-hand-scissors-o": "",
  // "fa-hand-lizard-o": "",
  // "fa-hand-spock-o": "",
  "fa-hand-pointer-o": "hand-index",
  // "fa-hand-peace-o": "",
  "fa-trademark": "badge-tm",
  // "fa-registered": "",
  // "fa-creative-commons": "",
  "fa-gg": "r-circle",
  // "fa-gg-circle": "",
  // "fa-tripadvisor": "",
  // "fa-odnoklassniki": "",
  // "fa-odnoklassniki-square": "",
  // "fa-get-pocket": "",
  "fa-wikipedia-w": "wikipedia",
  "fa-safari": "browser-safari",
  "fa-chrome": "browser-chrome",
  "fa-firefox": "browser-firefox",
  // "fa-opera": "",
  "fa-internet-explorer": "browser-edge",
  "fa-television": "tv",
  // "fa-contao": "",
  // "fa-500px": "",
  "fa-amazon": "amazon",
  "fa-calendar-plus-o": "calendar-plus",
  "fa-calendar-minus-o": "calendar-minus",
  "fa-calendar-times-o": "calendar-x",
  "fa-calendar-check-o": "calendar-check",
  "fa-industry": "buildings-fill",
  "fa-map-pin": "pin-map-fill",
  "fa-map-signs": "signpost-2-fill",
  "fa-map-o": "map",
  "fa-map": "map-fill",
  "fa-commenting": "chat-dots-fill",
  "fa-commenting-o": "chat-dots",
  // "fa-houzz": "",
  "fa-vimeo": "vimeo",
  // "fa-black-tie": "",
  // "fa-fonticons": "",
  "fa-reddit-alien": "reddit",
  "fa-edge": "browser-edge",
  "fa-credit-card-alt": "credit-card",
  // "fa-codiepie": "",
  // "fa-modx": "",
  // "fa-fort-awesome": "",
  "fa-usb": "usb-symbol",
  // "fa-product-hunt": "",
  // "fa-mixcloud": "",
  // "fa-scribd": "",
  "fa-pause-circle": "pause-circle-fill",
  "fa-pause-circle-o": "pause-circle",
  "fa-stop-circle": "stop-circle-fill",
  "fa-stop-circle-o": "stop-circle",
  "fa-shopping-bag": "bag-fill",
  "fa-shopping-basket": "basket-fill",
  "fa-hashtag": "hash",
  "fa-bluetooth": "bluetooth",
  "fa-bluetooth-b": "bluetooth",
  "fa-percent": "percent",
  "fa-gitlab": "gitlab",
  // "fa-wpbeginner": "",
  // "fa-wpforms": "",
  // "fa-envira": "",
  "fa-universal-access": "universal-access",
  // "fa-wheelchair-alt": "",
  "fa-question-circle-o": "question-circle",
  // "fa-blind": "",
  // "fa-audio-description": "",
  // "fa-volume-control-phone": "",
  // "fa-braille": "",
  // "fa-assistive-listening-systems": "",
  // "fa-american-sign-language-interpreting": "",
  // "fa-deaf": "",
  // "fa-glide": "",
  // "fa-glide-g": "",
  // "fa-sign-language": "",
  "fa-low-vision": "eye-slash-fill",
  // "fa-viadeo": "",
  // "fa-viadeo-square": "",
  "fa-snapchat": "snapchat",
  "fa-snapchat-ghost": "snapchat",
  "fa-snapchat-square": "snapchat",
  // "fa-pied-piper": "",
  // "fa-first-order": "",
  // "fa-yoast": "",
  // "fa-themeisle": "",
  "fa-google-plus-official": "google",
  // "fa-font-awesome": "",
  // "fa-handshake-o": "",
  "fa-envelope-open": "envelope-open-fill",
  "fa-envelope-open-o": "envelope-open",
  // "fa-linode": "",
  "fa-address-book": "person-vcard",
  "fa-address-book-o": "person-vcard",
  "fa-address-card": "person-vcard-fill",
  "fa-address-card-o": "person-vcard",
  "fa-user-circle": "person-circle",
  "fa-user-circle-o": "person-circle",
  "fa-user-o": "person",
  "fa-id-badge": "person-badge",
  "fa-id-card": "person-vcard-fill",
  "fa-id-card-o": "person-vcard",
  "fa-quora": "quora",
  // "fa-free-code-camp": "",
  "fa-telegram": "telegram",
  "fa-thermometer-full": "thermometer-high",
  "fa-thermometer-three-quarters": "thermometer-half",
  "fa-thermometer-half": "thermometer-half",
  "fa-thermometer-quarter": "thermometer-low",
  "fa-thermometer-empty": "thermometer",
  // "fa-shower": "",
  // "fa-bath": "",
  "fa-podcast": "broadcast-pin",
  "fa-window-maximize": "arrows-fullscreen",
  "fa-window-minimize": "fullscreen-exit",
  "fa-window-restore": "back",
  "fa-window-close": "window-dash",
  "fa-window-close-o": "window-dash",
  // "fa-bandcamp": "",
  // "fa-grav": "",
  // "fa-etsy": "",
  // "fa-imdb": "",
  // "fa-ravelry": "",
  // "fa-eercast": "",
  // "fa-microchip": "",
  // "fa-snowflake-o": "",
  // "fa-superpowers": "",
  // "fa-wpexplorer": "",
  //"fa-meetup": ""
};

/**
 * Map removed material icons with their equivalency in order to maintained compatibility
 * From 2024-05-14 to 2025-03-21 : see https://material-symbols-changelog.vercel.app/
 */
const materialIconsRemoved: Record<string, MaterialIconProps["icon"]> = {
  // 2024-05-14
  arrow_back_ios_new: "arrow_back_ios",
  done: "check",
  expand_less: "keyboard_arrow_up",
  expand_more: "keyboard_arrow_down",
  file_download_done: "download_done",
  navigate_before: "chevron_left",
  navigate_next: "chevron_right",
  // 2024-05-30
  cut: "content_cut",
  emoji_flags: "flag",
  feed: "description",
  monetization_on: "paid",
  // 2024-06-06
  wifi_calling_1: "wifi_calling_bar_3",
  wifi_calling_2: "wifi_calling_bar_2",
  wifi_calling_3: "wifi_calling_bar_3",
  // 2024-07-02
  airplanemode_active: "flight",
  clear_night: "bedtime",
  device_reset: "history",
  flightsmode: "travel",
  lens: "circle",
  panorama_fish_eye: "circle",
  quiet_time: "bedtime",
  quiet_time_active: "bedtime_off",
  // 2024-08-08
  restaurant_menu: "restaurant",
  // 2024-09-06
  ev_charger: "ev_station",
  // 2024-10-01
  pixel_9_pro_fold: "phone_android",
  reg_logo_ift: "communication",
  // 2024-10-11
  width: "arrow_range",
  // 2024-11-02
  grade: "star",
  // 2024-11-15
  add_to_photos: "library_add",
// 2025-02-10
  brightness_high: "brightness_7",
  brightness_low: "brightness_5",
  cloudy_snowing: "weather_snowy",
  // 2025-03-04
  nest_gale_wifi: "nest_wifi_router",
};

export type IconProps = {
  icon: string;
} & Pick<
  MaterialIconProps,
  "fill" | "color" | "fontSize" | "className" | "onClick"
>;

type MaterialIconName = MaterialIconProps["icon"];

const ignore = [
  "fa",
  "fa-fw",
  "fa-lg",
  "fa-2x",
  "fa-3x",
  "fa-4x",
  "fa-5x",
  "fa-spin",
  "fa-colored",
  "fa-rotate-90",
  "fa-rotate-180",
  "fa-rotate-270",
  "fa-flip-horizontal",
  "fa-flip-vertical",
];

const findName = (icon: string) => {
  return (
    icon
      .split(/\s+/g)
      .filter(Boolean)
      .filter((x) => !ignore.includes(x))
      .find(Boolean) ?? icon
  );
};

const findBsName = (icon: string) => {
  return findName(icon).replace(/^fa-/, "").replace(/-o$/, "");
};

const findMaterialIcon = (icon: string) => {
  let name = icon.replace(/-/g, "_");
  let found: MaterialIconName | undefined;

  if (materialIconNames.has(icon)) found = icon as MaterialIconName;
  if (materialIconNames.has(name)) found = name as MaterialIconName;
  if (materialIconsRemoved[name]) {
    if (
      process.env.NODE_ENV !== "production" &&
      !logsMissingIcons.includes(name)
    ) {
      console.log("Deprecated icon : " + name);
      logsMissingIcons.push(name);
    }
    found = materialIconsRemoved[name];
  }

  return found;
};

const findBootstrapIcon = (icon: string) => {
  const name = findName(icon);
  let found: BootstrapIconName | undefined;

  if (name && name.includes("fa-")) found = fa[name];
  if (!found) {
    const bsName = findBsName(name);
    if (bootstrapIconNames.has(name)) found = name as BootstrapIconName;
    if (bootstrapIconNames.has(bsName)) found = bsName as BootstrapIconName;
  }

  return found;
};

const logsMissingIcons: Array<string> = [];

export const Icon = forwardRef<HTMLElement, IconProps>(
  ({ icon, ...props }, ref) => {
    const mi = findMaterialIcon(icon);
    const bi = findBootstrapIcon(icon);

    if (mi) return <MaterialIcon icon={mi} {...props} ref={ref} />;
    if (bi) return <BootstrapIcon icon={bi} {...props} />;

    if (
      process.env.NODE_ENV !== "production" &&
      !logsMissingIcons.includes(icon)
    ) {
      console.log("Unknown icon : " + icon);
      logsMissingIcons.push(icon);
    }

    return <MaterialIcon icon="apps" {...props} ref={ref} />;
  },
);
